<template>
  <div>
    <div>
      <!-- 筛选框 -->
      <slot name="formSlot"></slot>
    </div>
    <div>
      <!-- 按钮 -->
      <slot name="btnSlot"> </slot>
    </div>
    <el-table
      :data="tableData"
      style="width: 100%"
      :max-height="maxHeight"
      :stripe="stripe"
      :border="border"
    >
     <el-table-column
     v-if="isindex"
     label="#"
      type="index">
     </el-table-column>
      <el-table-column type="expand" v-if="isexpand">
        <template slot-scope="props">
          <slot name="expandBox" v-bind:operationData="props.row"></slot>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item, index) in headerData"
        :prop="item.prop"
        :label="item.label"
        :key="index"
        :width="item.width"
         header-align="center"  
      >
        <template slot-scope="scope">
          <div v-if="item.slot">
            <slot :name="item.prop" v-bind:row="scope.row"></slot>
          </div>
          <div v-if="!item.slot">
            {{ tableData[scope.$index][item.prop] }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        v-if="isoperation"
        fixed="right"
        label="编辑"
        :width="tabelewidth"
         header-align="center"  
      >
        <template slot-scope="scope">
          <!-- <div>
                   <el-button icon="el-icon-edit" type="text">编辑</el-button>
                   <span class="pan">|</span>
                   <el-button icon="el-icon-setting" type="text">字典配置</el-button>
                   <span class="pan">|</span>
                   <el-button type="text">删除</el-button>
               
             </div> -->

          <!-- vue插槽 
                    什么时候使用vue插槽？
                    如果在子组件里面布局和功能在不同的模块页面不一样
                    的时候我们会使用插槽来插入到当前子组件
                    保持这个组件在其他页面不受影响
                    Vue插槽有哪些？
                    我只知道vue的插槽叫做slot
                -->
          <!-- <slot name="当前插槽的名字" v-bind:传入给插槽的数据的定义名="当前传入插槽的数据值"></slot> -->
          <slot name="operationBtn" v-bind:operationData="scope.row"></slot>
        </template>
      </el-table-column>
    </el-table>
    <!-- <el-pagination
        class="paginationStyle"
        v-if="paginationStyle"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentpage"
      :page-sizes="[10,20,30]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
      </el-pagination> -->
    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="活动名称" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="活动区域" :label-width="formLabelWidth">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      formLabelWidth: "120px",
    };
  },
  methods: {
    handleCurrentChange(val) {
      let _self = this;
      _self.$emit("CurrentChange", val);
    },
    
  },
  props: {
    /* 
            传入的数据的名字：{
                type:"该数据的数据类型",
                default:()=>{
                    retrun 如果父组件没有传递该数据 该数据显示会默认显示什么值
                }    
            }
            */
    //表格列表传递过来的数据
    tableData: {
      type: Array,
      default: () => {
        return [];
      },
    },
    // 是否显示序号
    isindex:{
       type: Boolean,
      default: () => {
        return false;
      },
    },
    // 表头数据
    headerData: {
      type: Array,
      default: () => {
        return [];
      },
    },
    // 是否显示斑马纹
    stripe: {
      type: Boolean,
      default: () => {
        return true;
      },
    },
    // 是否显示边框
    border: {
      type: Boolean,
      default: () => {
        return true;
      },
    },
    maxHeight: {
      type: Number,
      default: () => {
        return 600;
      },
    },
    // 是否操作
    isoperation: {
      type: Boolean,
      default: () => {
        return true;
      },
    },
    // 是否操作
    ispagination: {
      type: Boolean,
      default: () => {
        return true;
      },
    },
    // 当前第几页
    currentpage: {
      type: Number,
      default: () => {
        return 1;
      },
    },
    // 一页多少条
    pagesize: {
      type: Number,
      default: () => {
        return 10;
      },
    },
    //总条件
    total: {
      type: Number,
      default: () => {
        return 0;
      },
    },
    // 是否有下拉箭头数据
    isexpand: {
      type: Boolean,
      default: () => {
        return false;
      },
    },
    // 是否显示分页
    paginationStyle: {
      type: Boolean,
      default: () => {
        return true;
      },
    },
    tabelewidth: {
      type: Number,
      default: () => {
        return 300;
      },
    },
  },
};
</script>

<style>
.paginationStyle {
  margin-top: 20px;
  margin-left: 20px;
}
.pan {
  color: #e8e8e8;
  padding: 5px;
}
</style>